#ifndef _SHAPE_
#define _SHAPE_

namespace air {

#define SHP_CIRCLE	0x1
#define SHP_RECT	0x2

	class Shape {
	public:
		virtual Shape* duplicate() = 0;
		virtual bool isPointInShape(float x, float y) = 0;

		virtual float getPositionX() const = 0;
		virtual float getPositionY() const = 0;
		virtual int getType() = 0;
		virtual ~Shape() {
		}
	};

	class Circle: public Shape {
	public:
		Circle(float x, float y, float r): cx(x), cy(y), radius(r) {
		};
		bool isPointInShape(float x, float y) {
			if ((x-cx)*(x-cx) + (y-cy)*(y-cy) <= radius*radius) {
				return true;
			} else {
				return false;
			}
		}
		Shape* duplicate() {
			return new Circle(cx, cy, radius);
		}
		float getPositionX() const {
			return cx;
		}
		float getPositionY() const {
			return cy;
		}

		int getType() {
			return SHP_CIRCLE;
		}

	private:
		float cx, cy, radius;
	};

	class Rect: public Shape {
	public:
		Rect(float _ltx, float _lty, float _rbx, float _rby)
			: ltx(_ltx), lty(_lty), rbx(_rbx), rby(_rby) 
		{
		}

		Shape* duplicate() {
			return new Rect(ltx, lty, rbx, rby);
		}

		bool isPointInShape(float x, float y) {
			if (x <= rbx && x >= ltx && y >= lty && y <= rby) {
				return true;
			} else {
				return false;
			}
		}
		
		float getPositionX() const {
			return ltx;
		}
		float getPositionY() const {
			return lty;
		}
		float getPositionX2() const {
			return rbx;
		}
		float getPositionY2() const {
			return rby;
		}

		float W() const {
			return rbx - ltx;
		}

		float H() const {
			return rby - lty;
		}

		int getType() {
			return SHP_RECT;
		}

	private:
		float ltx, lty, rbx, rby;	
	};

}

#endif